import Taro, { Component } from '@tarojs/taro'
import { connect } from '@tarojs/redux'

import { View} from '@tarojs/components'
import { AtTabBar } from 'taro-ui'
import { getChatUserId } from '../../actions/message'
import { IMAppId } from '../../utils/constants'
import { removeStorageOrderData } from '@/utils'
import TIM from 'tim-js-sdk'

import './index.scss'

let options = {
  SDKAppID: IMAppId
};
let tim = TIM.create(options); 

@connect(({ common }) => ({
  common
}))
class Main extends Component {

  config = {
    navigationBarTitleText: '首页'
  }

  constructor(props){
    super(props)
    this.state = {
      current: 0,
      unRead: false,
      searchKey: '',
    }
  }

  componentDidMount(){
  }

  render () {
    return (
      <View className='index-page'>
        <View className='index-top'></View>
        <View className='index-top-btns'>
          <View className='item-btn top-btn' onClick={() => this.jump2page('myorder')}>
            <View className='item-img img-order'></View>
            <View>我的订单</View>
          </View>
          <View className='item-btn top-btn' onClick={() => this.jump2page('mynews')}>
            <View className='item-img img-im'></View>
            <View>我的消息</View>
          </View>
        </View>
        <View className='index-mid'>
          <View className='item-btn top-btn' onClick={() => this.jump2page('air_traffic')}>
            <View className='item-img img-air'></View>
            <View>空运下单</View>
          </View>
          <View className='item-btn top-btn' onClick={() => this.jump2page('special_line_traffic')}>
            <View className='item-img img-line'></View>
            <View>专线物流</View>
          </View>
          <View className='item-btn top-btn' onClick={() => this.jump2page('distribution')}>
            <View className='item-img img-citymatch'></View>
            <View>城市配送</View>
          </View>
          <View className='item-btn top-btn' onClick={() => this.jump2page('sales')}>
            <View className='item-img img-sales'></View>
            <View>促销活动</View>
          </View>
        </View>
      </View>
    )
  }

  jump2page = (path) => {
    switch (path) {
      case 'air_traffic':
        removeStorageOrderData()
        Taro.navigateTo({url: `/pages/order/orderair/index?type=${path}`})
        break;
      case 'special_line_traffic':
        removeStorageOrderData()
        Taro.navigateTo({url: `/pages/order/orderline/index?type=${path}`})
        break;
      default:
        Taro.showToast({title: '待开放', icon: 'none'})
        break;
    }
  }
}

export default Main
